package com.skt.domain.ENUM;

/**
 * 日志级别枚举
 */
public enum LogLevel {
    TRACE("TRACE", 1),
    DEBUG("DEBUG", 2),
    INFO("INFO", 3),
    WARN("WARN", 4),
    ERROR("ERROR", 5);
    
    private final String level;
    private final int code;
    
    LogLevel(String level, int code) {
        this.level = level;
        this.code = code;
    }
    
    public String getLevel() {
        return level;
    }
    
    public int getCode() {
        return code;
    }
    
    public static LogLevel getByCode(int code) {
        for (LogLevel logLevel : values()) {
            if (logLevel.getCode() == code) {
                return logLevel;
            }
        }
        return INFO;
    }
}